return way;
}
+static int
+waypt_write_cb(GPS_PWay *way)
+{
+ static int i;
+
+ if (global_opts.verbose_status) {
+ fprintf(stdout, "%d\r", ++i*100/waypt_count());
+ fflush(stdout);
+ }
+ return 0;
+}
static void
waypoint_write(void)
if (wpt->altitude != unknown_alt) {
way[i]->alt = wpt->altitude;
}
- if (global_opts.verbose_status) {
- fprintf(stdout, "%d\r", i*100/n);
- fflush(stdout);
- }
i++;
}
- if ((ret = GPS_Command_Send_Waypoint(portname, way, n)) < 0) {
+ if ((ret = GPS_Command_Send_Waypoint(portname, way, n, waypt_write_cb)) < 0) {
fatal(MYNAME ":communication error sending wayoints..\n");
}
}
if (global_opts.verbose_status) {
fprintf(stdout, "\r\n");
+ fflush(stdout);
}
xfree(way);
}
#include <time.h>
#include <stdlib.h>
-
static int32 GPS_A000(const char *port);
static void GPS_A001(GPS_PPacket packet);
**
** @return [int32] success
************************************************************************/
-int32 GPS_A100_Send(const char *port, GPS_PWay *way, int32 n)
+int32 GPS_A100_Send(const char *port, GPS_PWay *way, int32 n, int (*cb)())
{
UC data[GPS_ARB_LEN];
int32 fd;
for(i=0;i<n;++i)
{
+ if (cb) {
+ if (cb(way[i]))
+ break;
+ }
+
switch(gps_waypt_type)
{
case pD100:
return gps_errno;
}
}
-
+
GPS_Util_Put_Short(data,COMMAND_ID[gps_device_command].Cmnd_Transfer_Wpt);
GPS_Make_Packet(&tra, LINK_ID[gps_link_type].Pid_Xfer_Cmplt,
data,2);
int32 GPS_Init(const char *port);
int32 GPS_A100_Get(const char *port, GPS_PWay **way);
-int32 GPS_A100_Send(const char *port, GPS_PWay *way, int32 n);
+int32 GPS_A100_Send(const char *port, GPS_PWay *way, int32 n, int (*cb)(GPS_PWay *));
int32 GPS_A200_Get(const char *port, GPS_PWay **way);
int32 GPS_A201_Get(const char *port, GPS_PWay **way);
** @return [int32] success
************************************************************************/
-int32 GPS_Command_Send_Waypoint(const char *port, GPS_PWay *way, int32 n)
+int32 GPS_Command_Send_Waypoint(const char *port, GPS_PWay *way, int32 n, int (*cb)())
{
int32 ret=0;
switch(gps_waypt_transfer)
{
case pA100:
- ret = GPS_A100_Send(port, way, n);
+ ret = GPS_A100_Send(port, way, n, cb);
break;
default:
GPS_Error("Send_Waypoint: Unknown waypoint protocol");
int32 GPS_Command_Send_Track(const char *port, GPS_PTrack *trk, int32 n);
int32 GPS_Command_Get_Waypoint(const char *port, GPS_PWay **way);
-int32 GPS_Command_Send_Waypoint(const char *port, GPS_PWay *way, int32 n);
+int32 GPS_Command_Send_Waypoint(const char *port, GPS_PWay *way, int32 n, int (*cb)());
int32 GPS_Command_Get_Proximity(const char *port, GPS_PWay **way);
int32 GPS_Command_Send_Proximity(const char *port, GPS_PWay *way, int32 n);